package com.example.wechat.controller;

import java.util.List;

import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.project.core.controller.BaseController;
import com.example.project.core.domain.AjaxResult;
import com.example.project.entity.User;
import com.example.wechat.model.WechatConversation;
import com.example.wechat.model.WechatMessage;
import com.example.wechat.model.WechatUserContact;
import com.example.wechat.service.WechatConversationService;
import com.example.wechat.service.WechatMessageService;

/**
 * 微信聊天消息Controller
 * 
 * @author ruoyi
 * @date 2025-11-12
 */
@Controller
@RequestMapping("/wechat/message")
public class WechatMessageController extends BaseController {

	@Autowired
	private WechatMessageService wechatMessageService;

	@Autowired
	private WechatConversationService wechatConversationService;

	@GetMapping("/queryList")
	@ResponseBody
	public AjaxResult queryList(long targetId) {
		Integer sessionType = 1;
		long userId = getUserId();
		List<WechatMessage> list = Lists.newArrayList();
		// 获取会话
		WechatConversation conversation = wechatConversationService.queryConversation(userId, targetId, sessionType);
		if (conversation != null) {
			Long conversationId = conversation.getId();

			list = wechatMessageService.queryByConversationId(conversationId);
		}
		return success(list);
	}
}
